import copy


class Solution(object):
    def findRotation(self, mat, target):
        m = len(mat)
        n = len(mat[0])
        if mat == target:
            return True

        def rotate(mat):
            new_mat = copy.deepcopy(mat)
            for i in range(m):
                for j in range(n):
                    new_mat[j][n - 1 - i] = mat[i][j]
            return new_mat

        mat = rotate(mat)
        if mat == target:
            return True
        mat = rotate(mat)
        if mat == target:
            return True
        mat = rotate(mat)
        if mat == target:
            return True
        return False